{block #mainTitle}Vzorkovna{/block}
{block #content}
<div id="dialog-confirm" style="display:none;">
    <p>
        <span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;">
        </span>Opravdu si přejete kóji trvale odstranit?
    </p>
</div>

<div id="breadcrumb">
    <span class="breadcrumb">Vzorkovna</span>
</div>

<a class="button-add" href="{link Vzorkovna:pridat}">Přidat</a>   
<table class="data-table" n:if="count($showrooms)">    
    <thead>
        <tr>
            <th>Id</th>
            <th>Název</th>            
            <th>Výrobce</th>
            <th>Stav</th>
            <th>Akce</th>            
        </tr>
    </thead>
    <tbody>        
        <tr n:foreach="$showrooms as $showroom">
            <td>{$showroom->id_showroom}</td>
            <td>{$showroom->title}</td>
            <td>{$showroom->manufacturer->title}</td>
            <td>
            {if $showroom->published}Uveřejněno{else}Neuveřejněno{/if}
            (obrázků: {? echo count($showroom->related('showroom_has_images')); },
            položek: {? echo count($showroom->related('showroom_has_tiles')); })
            </td>
            <td>
                <a class="action-icon-edit" href="{link upravit $showroom->id_showroom}">upravit</a>
                <a class="action-icon-image" href="{link obrazky $showroom->id_showroom}">obrázky</a>
                <a class="action-icon-note" href="{link polozky $showroom->id_showroom}">položky</a>
                {if $showroom->published}
                <a class="ajax action-icon-unpublish" href="{link stahnout! $showroom->id_showroom}">stáhnout z webu</a>
                {else}
                <a class="ajax action-icon-publish" href="{link zverejnit! $showroom->id_showroom}">zveřejnit</a>
                {/if}
                <a class="action-icon-delete" href="{link smazat! $showroom->id_showroom}">smazat</a>
            </td>
        </tr>        
    </tbody>
    <script type="text/javascript">
        // TODO: modalni dialog jako funkce
        initButtons();
        initAjaxLinks();
        
        $(function() {
            $(".action-icon-delete").bind('click', showModal);
            function showModal() {
                var link = this.href;                
                $('#dialog-confirm').dialog({
                        modal: true,
                        closeText: 'zavřít',
                        title: 'Smazání kóje nabídky',
                        buttons: {
                            'Ano':function(event) {
                                event.preventDefault();
                                $.get(link);
                                $(this).dialog('close');
                            },
                            'Ne': function() {
                                $(this).dialog('close');
                            }
                        }
                });
                return false;
            };
        });
    </script>
</table>
{/block}
